home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 February: Tool Chest / Apple Developer CD Series Tool Chest February 1996 (Apple Computer)(1996).iso / Tool Chest / Development Tools & Languages / Macintosh Common Lisp Related / interfaces / PInterface Translator / PInterfaces / osa.p < prev    next >
Encoding:
Text File  |  1993-09-16  |  15.4 KB  |  545 lines  |  [TEXT/CCL2]

  1. {
  2. ////////////////////////////////////////////////////////////////////////////
  3. ////
  4. // OPEN SCRIPTING ARCHITECTURE: Client Interface
  5. ////////////////////////////////////////////////////////////////////////////
  6. ////
  7. // Copyright   1992 Apple Computer, Inc. All rights reserved.
  8. // Authors: Jens Alfke, William Cook, Donn Denman, and Warren Harris
  9. ////////////////////////////////////////////////////////////////////////////
  10. ////
  11. // This interface defines what it means to be a "scripting component."
  12. // Scripting components allow "scripts" to be loaded and executed.  This
  13. // interface does not define the way in which a particular scripting
  14. // component's scripts are editing and debugged.
  15. ////////////////////////////////////////////////////////////////////////////
  16. ////
  17. }
  18.  
  19. {$IFC UNDEFINED UsingIncludes}
  20. {$SETC UsingIncludes := 0}
  21. {$ENDC}
  22.  
  23. {$IFC NOT UsingIncludes}
  24.     UNIT OSA;
  25.     INTERFACE
  26. {$ENDC}
  27.  
  28. {$IFC UNDEFINED UsingOSA}
  29. {$SETC UsingOSA := 1}
  30.  
  31. {$I+}
  32. {$SETC OSAIncludes := UsingIncludes}
  33. {$SETC UsingIncludes := 1}
  34. {$IFC UNDEFINED UsingAppleEvents}
  35. {$I $$Shell(PInterfaces)AppleEvents.p}
  36. {$ENDC}
  37. {$IFC UNDEFINED UsingComponents}
  38. {$I $$Shell(PInterfaces)Components.p}
  39. {$ENDC}
  40. {$SETC UsingIncludes := OSAIncludes}
  41.  
  42. { Types and Constants }
  43. CONST
  44.     kOSAComponentType                            = 'osa ';
  45.     kOSAGenericScriptingComponentSubtype        = 'scpt';
  46.  
  47. TYPE
  48.     OSAID                            = LONGINT;
  49.     OSAError                        = ComponentResult;
  50.  
  51. CONST
  52.     kOSANullScript                    = 0;
  53.     
  54.     kOSAScriptResourceType            = kOSAGenericScriptingComponentSubtype;
  55.     typeOSAGenericStorage            = kOSAScriptResourceType;
  56.  
  57.     { Error Codes }
  58.     errOSACorruptData                = -1702;    { Same as errAECorruptData }
  59.     errOSASystemError                = -1750;
  60.     errOSAInvalidID                    = -1751;
  61.     errOSABadStorageType            = -1752;
  62.     errOSAScriptError                = -1753;
  63.     errOSABadSelector                = -1754;
  64.     errOSAInvalidAccess                = -1755;
  65.     errOSARecordingIsAlreadyOn        = -30009;
  66.  
  67. {
  68. ////////////////////////////////////////////////////////////////////////////
  69. ////
  70. // OSA Interface Descriptions
  71. ////////////////////////////////////////////////////////////////////////////
  72. ////
  73. // The OSA Interface is broken down into a required interface, and several
  74. // optional interfaces to support additional functionality.  A given
  75. scripting
  76. // component may choose to support only some of the optional interfaces in
  77. // addition to the basic interface.  The OSA Component Flags may be used to
  78.  
  79. // query the Component Manager to find a scripting component with a
  80. particular
  81. // capability, or determine if a particular scripting component supports a 
  82. // particular capability.
  83. ////////////////////////////////////////////////////////////////////////////
  84. ////
  85. }
  86.     
  87.     { OSA Component Flags }
  88.     kOSASupportsCompiling                = 2**0;
  89.     kOSASupportsGetSource                = 2**1;
  90.     kOSASupportsAECoercion                = 2**2;
  91.     kOSASupportsAESending                = 2**3;
  92.     kOSASupportsRecording                = 2**4;
  93.     kOSASupportsWindowEditing            = 2**5;
  94.     kOSASupportsDialects                = 2**6;
  95.     kOSASupportsTinkering                = 2**7;
  96.     
  97.     { Component Selectors }
  98.     { Basic Scripting: }
  99.     kOSASelectLoad                        = $0001;
  100.     kOSASelectStore                        = $0002;
  101.     kOSASelectExecute                    = $0003;
  102.     kOSASelectDisplay                    = $0004;
  103.     kOSASelectScriptError                = $0005;
  104.     kOSASelectDispose                    = $0006;
  105.     kOSASelectSetScriptInfo                = $0007;
  106.     kOSASelectGetScriptInfo                = $0008;
  107.     kOSASelectSetActiveProc                = $0009;
  108.     kOSASelectGetActiveProc                = $000A;
  109.     { Compiling: }
  110.     kOSASelectExactScriptingComponent    = $0101;
  111.     kOSASelectScriptingComponentName    = $0102;
  112.     kOSASelectCompile                    = $0103;
  113.     kOSASelectCopyID                    = $0104;
  114.     { GetSource: }
  115.     kOSASelectGetSource                    = $0201;
  116.     { AECoercion: }
  117.     kOSASelectCoerceFromDesc            = $0301;
  118.     kOSASelectCoerceToDesc                = $0302;
  119.     { AESending: }
  120.     kOSASelectSetSendProc                = $0401;
  121.     kOSASelectGetSendProc                = $0402;
  122.     kOSASelectSetCreateProc                = $0403;
  123.     kOSASelectGetCreateProc                = $0404;
  124.     { Recording: }
  125.     kOSASelectStartRecording            = $0501;
  126.     kOSASelectStopRecording                = $0502;
  127.     { WindowEditing:
  128.     kOSASelectOpenEditor                = $0601;
  129.     kOSASelectCloseEditor                = $0602;
  130.     { Dialects: }
  131.     kOSASelectSetCurrentDialect            = $0701;
  132.     kOSASelectGetCurrentDialect            = $0702;
  133.     kOSASelectAvailableDialects            = $0703;
  134.     { Tinkering: }
  135.     kOSASelectExecuteEvent                = $0801;
  136.     kOSASelectMakeContext                = $0802;
  137.  
  138.     kOSASelectComponentSpecificStart    = $1001;
  139.     { scripting component specific selectors are added beginning with this 
  140.       value }
  141.  
  142. {
  143. ////////////////////////////////////////////////////////////////////////////
  144. ////
  145. // OSA Basic Scripting Interface
  146. ////////////////////////////////////////////////////////////////////////////
  147. ////
  148. // Scripting components must at least support the Basic Scripting
  149. interface.
  150. ////////////////////////////////////////////////////////////////////////////
  151. ////
  152. }
  153.  
  154. { Loading and Storing Scripts }
  155.  
  156. FUNCTION
  157. OSALoad(scriptingComponent        : ComponentInstance;
  158.         scriptData                : AEDesc;
  159.         VAR resultingScriptID    : OSAID)
  160.     : OSAError;
  161.     INLINE $2F3C, $0008, $0001, $7000, $A82A;
  162.  
  163. FUNCTION
  164. OSAStore(scriptingComponent            : ComponentInstance; 
  165.          scriptID                    : OSAID; 
  166.          desiredType                : DescType;
  167.          VAR resultingScriptData    : AEDesc)
  168.     : OSAError;
  169.     INLINE $2F3C, $000C, $0002, $7000, $A82A;
  170.  
  171. { Executing Scripts }
  172.  
  173. FUNCTION
  174. OSAExecute(scriptingComponent            : ComponentInstance;
  175.            compiledScriptID                : OSAID;
  176.            contextID                    : OSAID;
  177.            modeFlags                    : LONGINT;
  178.            VAR resultingScriptValueID    : OSAID)
  179.     : OSAError;
  180.     INLINE $2F3C, $0010, $0003, $7000, $A82A;
  181.  
  182. { Displaying Results }
  183.  
  184. FUNCTION
  185. OSADisplay(scriptingComponent        : ComponentInstance;
  186.            scriptValueID            : OSAID;
  187.            desiredType                : DescType;
  188.            modeFlags                : LONGINT;
  189.            VAR resultingText        : AEDesc)
  190.     : OSAError;
  191.     INLINE $2F3C, $0010, $0004, $7000, $A82A;
  192.  
  193. { Getting Error Information }
  194.  
  195. FUNCTION
  196. OSAScriptError(scriptingComponent                : ComponentInstance;
  197.                selector                            : OSType;
  198.                desiredType                        : DescType;
  199.                VAR resultingErrorDescription    : AEDesc)
  200.     : OSAError;
  201.     INLINE $2F3C, $000C, $0005, $7000, $A82A;
  202.  
  203. CONST    { OSAScriptError selectors: }
  204.     kOSAErrorNumber                = 'errn';
  205.     kOSAErrorMessage            = 'errs';
  206.     kOSAErrorBriefMessage        = 'errb';
  207.     kOSAErrorApp                = 'erap';
  208.     kOSAErrorPartialResult        = 'ptlr';
  209.     kOSAErrorOffendingObject    = 'erob';
  210.     kOSAErrorRange                = 'erng';
  211.  
  212.         { text ranges: }
  213.     typeOSAErrorRange            = 'erng';
  214.     keySourceStart                = 'srcs';
  215.     keySourceEnd                = 'srce';
  216.  
  217. { Disposing Script IDs }
  218.  
  219. FUNCTION
  220. OSADispose(scriptingComponent    : ComponentInstance;
  221.            scriptID                : OSAID)
  222.     : OSAError;
  223.     INLINE $2F3C, $0004, $0006, $7000, $A82A;
  224.  
  225. { Getting and Setting Script Information }
  226.  
  227. FUNCTION
  228. OSASetScriptInfo(scriptingComponent    : ComponentInstance;
  229.                  scriptID            : OSAID;
  230.                  selector            : OSType;
  231.                  value                : LONGINT)
  232.     : OSAError;
  233.     INLINE $2F3C, $000C, $0007, $7000, $A82A;
  234.  
  235. FUNCTION
  236. OSAGetScriptInfo(scriptingComponent    : ComponentInstance;
  237.                  scriptID            : OSAID;
  238.                  selector            : OSType;
  239.                  VAR result            : LONGINT)
  240.     : OSAError;
  241.     INLINE $2F3C, $000C, $0008, $7000, $A82A;
  242.  
  243. CONST    { selectors }
  244.     kOSAScriptIsModified            = 'modi';
  245.     kOSAScriptIsBeingEdited            = 'edit';
  246.     kOSAScriptIsBeingRecorded        = 'recd';
  247.     kOSAScriptIsTypeCompiledScript    = 'cscr';
  248.     kOSAScriptIsTypeScriptValue        = 'valu';
  249.     kOSAScriptIsTypeScriptContext    = 'cntx';
  250.     kOSAScriptBestType                = 'best';
  251.  
  252. { Manipulating the ActiveProc }
  253.  
  254. TYPE
  255.     OSAActiveProcPtr = ProcPtr;
  256.  
  257. FUNCTION
  258. OSASetActiveProc(scriptingComponent    : ComponentInstance;
  259.                  activeProc            : OSAActiveProcPtr;
  260.                  refCon                : LONGINT)
  261.     : OSAError;
  262.     INLINE $2F3C, $0008, $0009, $7000, $A82A;
  263.  
  264. FUNCTION
  265. OSAGetActiveProc(scriptingComponent    : ComponentInstance;
  266.                  VAR activeProc        : OSAActiveProcPtr;
  267.                  VAR refCon            : LONGINT)
  268.     : OSAError;
  269.     INLINE $2F3C, $0008, $000A, $7000, $A82A;
  270.  
  271. {
  272. ////////////////////////////////////////////////////////////////////////////
  273. ////
  274. // OSA Optional Compiling Interface
  275. ////////////////////////////////////////////////////////////////////////////
  276. ////
  277. // Scripting components that support the Compiling interface have the 
  278. // kOSASupportsCompiling bit set in it's ComponentDescription.
  279. ////////////////////////////////////////////////////////////////////////////
  280. ////
  281. }
  282.  
  283. FUNCTION
  284. OSAExactScriptingComponent(
  285.             scriptingComponent            : ComponentInstance;
  286.             scriptID                    : OSAID;
  287.             VAR exactScriptingComponent    : ComponentInstance)
  288.     : OSAError;
  289.     INLINE $2F3C, $0008, $0101, $7000, $A82A;
  290.  
  291. FUNCTION
  292. OSAScriptingComponentName(
  293.             scriptingComponent                    : ComponentInstance;
  294.             VAR resultingScriptingComponentName    : AEDesc)
  295.     : OSAError;
  296.     INLINE $2F3C, $0004, $0102, $7000, $A82A;
  297.  
  298. FUNCTION
  299. OSACompile(scriptingComponent                : ComponentInstance;
  300.            sourceData                        : AEDesc;
  301.            modeFlags                        : LONGINT;
  302.            VAR resultingCompiledScriptID    : OSAID)
  303.     : OSAError;
  304.     INLINE $2F3C, $000C, $0103, $7000, $A82A;
  305.  
  306. FUNCTION
  307. OSACopyID(scriptingComponent    : ComponentInstance;
  308.           fromID                : OSAID;
  309.           VAR toID                : OSAID)
  310.     : OSAError;
  311.     INLINE $2F3C, $0008, $0104, $7000, $A82A;
  312.  
  313. {
  314. ////////////////////////////////////////////////////////////////////////////
  315. ////
  316. // OSA Optional GetSource Interface
  317. ////////////////////////////////////////////////////////////////////////////
  318. ////
  319. // Scripting components that support the GetSource interface have the 
  320. // kOSASupportsGetSource bit set in it's ComponentDescription.
  321. ////////////////////////////////////////////////////////////////////////////
  322. ////
  323. }
  324.  
  325. FUNCTION
  326. OSAGetSource(scriptingComponent            : ComponentInstance;
  327.              scriptID                    : OSAID;
  328.              desiredType                : DescType;
  329.              VAR resultingSourceData    : AEDesc)
  330.     : OSAError;
  331.     INLINE $2F3C, $000C, $0201, $7000, $A82A;
  332.  
  333. {
  334. ////////////////////////////////////////////////////////////////////////////
  335. ////
  336. // OSA Optional AECoercion Interface
  337. ////////////////////////////////////////////////////////////////////////////
  338. ////
  339. // Scripting components that support the AECoercion interface have the 
  340. // kOSASupportsGetSource bit set in it's ComponentDescription.
  341. ////////////////////////////////////////////////////////////////////////////
  342. ////
  343. }
  344.  
  345. FUNCTION
  346. OSACoerceFromDesc(scriptingComponent            : ComponentInstance;
  347.                   scriptData                    : AEDesc;
  348.                   VAR resultingScriptValueID    : OSAID)
  349.     : OSAError;
  350.     INLINE $2F3C, $0008, $0301, $7000, $A82A;
  351.  
  352. FUNCTION
  353. OSACoerceToDesc(scriptingComponent    : ComponentInstance;
  354.                 scriptValueID        : OSAID;
  355.                 desiredType            : DescType;
  356.                 VAR result            : AEDesc)
  357.     : OSAError;
  358.     INLINE $2F3C, $000C, $0302, $7000, $A82A;
  359.  
  360. {
  361. ////////////////////////////////////////////////////////////////////////////
  362. ////
  363. // OSA Optional AESending Interface
  364. ////////////////////////////////////////////////////////////////////////////
  365. ////
  366. // Scripting components that support the AESending interface have the 
  367. // kOSASupportsAESending bit set in it's ComponentDescription.
  368. ////////////////////////////////////////////////////////////////////////////
  369. ////
  370. }
  371.  
  372. TYPE 
  373.     AESendProcPtr = ProcPtr;
  374.     AECreateAppleEventProcPtr = ProcPtr;
  375.     
  376. {  The first two proc pointers have the following interfaces
  377.    taken from AppleEvents.p 
  378.    
  379.     FUNCTION AECreateAppleEvent(theAEEventClass: AEEventClass;
  380.                                 theAEEventID: AEEventID;
  381.                                 target: AEAddressDesc;
  382.                                 returnID: INTEGER;
  383.                                 transactionID: LONGINT;
  384.                                 VAR result: AppleEvent): OSErr;
  385.     
  386.     FUNCTION AESend(theAppleEvent: AppleEvent;
  387.                     VAR reply: AppleEvent;
  388.                     sendMode: AESendMode;
  389.                     sendPriority: AESendPriority;
  390.                     timeOutInTicks: LONGINT;
  391.                     idleProc: IdleProcPtr;
  392.                     filterProc: EventFilterProcPtr): OSErr;
  393.  
  394.     FUNCTION OSAActive(): OSErr;
  395.  
  396. }
  397.  
  398. FUNCTION
  399. OSASetSendProc(scriptingComponent    : ComponentInstance;
  400.                sendProc                : AESendProcPtr;
  401.                refCon                : LONGINT)
  402.     : OSAError;
  403.     INLINE $2F3C, $0008, $0401, $7000, $A82A;
  404.  
  405. FUNCTION
  406. OSAGetSendProc(scriptingComponent    : ComponentInstance;
  407.                VAR sendProc            : AESendProcPtr;
  408.                VAR refCon            : LONGINT)
  409.     : OSAError;
  410.     INLINE $2F3C, $0008, $0402, $7000, $A82A;
  411.  
  412. FUNCTION
  413. OSASetCreateProc(scriptSystem        : ComponentInstance;
  414.                  createProc            : AECreateAppleEventProcPtr;
  415.                  refCon                : LONGINT)
  416.     : OSAError;
  417.     INLINE $2F3C, $0008, $0403, $7000, $A82A;
  418.  
  419. FUNCTION
  420. OSAGetCreateProc(scriptSystem        : ComponentInstance;
  421.                  VAR createProc        : AECreateAppleEventProcPtr;
  422.                  VAR refCon            : LONGINT)
  423.     : OSAError;
  424.     INLINE $2F3C, $0008, $0404, $7000, $A82A;
  425.  
  426. {
  427. ////////////////////////////////////////////////////////////////////////////
  428. ////
  429. // OSA Optional Recording Interface
  430. ////////////////////////////////////////////////////////////////////////////
  431. ////
  432. // Scripting components that support the Recording interface have the 
  433. // kOSASupportsRecording bit set in it's ComponentDescription.
  434. ////////////////////////////////////////////////////////////////////////////
  435. ////
  436. }
  437.  
  438. FUNCTION
  439. OSAStartRecording(scriptingComponent            : ComponentInstance;
  440.                   VAR compiledScriptToModifyID    : OSAID)
  441.     : OSAError;
  442.     INLINE $2F3C, $0004, $0501, $7000, $A82A;
  443.  
  444. FUNCTION
  445. OSAStopRecording(scriptingComponent        : ComponentInstance;
  446.                  compiledScriptID        : OSAID)
  447.     : OSAError;
  448.     INLINE $2F3C, $0004, $0502, $7000, $A82A;
  449.  
  450. {
  451. ////////////////////////////////////////////////////////////////////////////
  452. ////
  453. // OSA Optional WindowEditing Interface
  454. ////////////////////////////////////////////////////////////////////////////
  455. ////
  456. // Scripting components that support the WindowEditing interface have the 
  457. // kOSASupportsWindowEditing bit set in it's ComponentDescription.
  458. ////////////////////////////////////////////////////////////////////////////
  459. ////
  460. }
  461.  
  462. FUNCTION 
  463. OSAOpenEditor(scriptingComponent            : ComponentInstance;
  464.               VAR compiledScriptToModifyID    : OSAID)
  465.     : OSAError;
  466.     INLINE $2F3C, $0004, $0601, $7000, $A82A;
  467.  
  468. FUNCTION 
  469. OSACloseEditor(scriptingComponent    : ComponentInstance;
  470.                compiledScriptID        : OSAID)
  471.     : OSAError;
  472.     INLINE $2F3C, $0004, $0602, $7000, $A82A;
  473.  
  474. {
  475. ////////////////////////////////////////////////////////////////////////////
  476. ////
  477. // OSA Optional Dialects Interface
  478. ////////////////////////////////////////////////////////////////////////////
  479. ////
  480. // Scripting components that support the Dialects interface have the 
  481. // kOSASupportsDialects bit set in it's ComponentDescription.
  482. ////////////////////////////////////////////////////////////////////////////
  483. ////
  484. }
  485.  
  486. FUNCTION 
  487. OSASetCurrentDialect(scriptingComponent    : ComponentInstance;
  488.                      dialectCode        : INTEGER)
  489.     : OSAError;
  490.     INLINE $2F3C, $0002, $0701, $7000, $A82A;
  491.  
  492. FUNCTION 
  493. OSAGetCurrentDialect(scriptingComponent            : ComponentInstance;
  494.                      VAR resultingDialectCode    : INTEGER)
  495.     : OSAError;
  496.     INLINE $2F3C, $0004, $0702, $7000, $A82A;
  497.  
  498. FUNCTION 
  499. OSAAvailableDialects(scriptingComponent                : ComponentInstance;
  500.                      VAR resultingDialectInfoList    : AEDesc)
  501.     : OSAError;
  502.     INLINE $2F3C, $0004, $0703, $7000, $A82A;
  503.  
  504. CONST
  505.     typeOSADialectInfo                    = 'difo';
  506.     keyOSADialectName                    = 'dnam';
  507.     keyOSADialectCode                    = 'dcod';
  508.  
  509. {
  510. ////////////////////////////////////////////////////////////////////////////
  511. ////
  512. // OSA Optional Tinkering Interface
  513. ////////////////////////////////////////////////////////////////////////////
  514. ////
  515. // Scripting components that support the Tinkering interface have the 
  516. // kOSASupportsTinkering bit set in it's ComponentDescription.
  517. ////////////////////////////////////////////////////////////////////////////
  518. ////
  519. }
  520.  
  521. FUNCTION
  522. OSAExecuteEvent(scriptingComponent    : ComponentInstance;
  523.                 theAppleEvent        : AppleEvent;
  524.                 contextID            : OSAID;
  525.                 defaultHandler        : EventHandlerProcPtr;
  526.                 modeFlags            : LONGINT;
  527.                 VAR reply            : AppleEvent;
  528.                 refCon                : LONGINT)
  529.     : OSAError;
  530.     INLINE $2F3C, $0018, $0801, $7000, $A82A;
  531.  
  532. FUNCTION
  533. OSAMakeContext(scriptingComponent        : ComponentInstance;
  534.                contextName                : StringPtr;
  535.                parentContext            : OSAID;
  536.                VAR resultingContextID    : OSAID)
  537.     : OSAError;
  538.     INLINE $2F3C, $000C, $0802, $7000, $A82A;
  539.  
  540. {$ENDC}    { UsingOSA }
  541.  
  542. {$IFC NOT UsingIncludes}
  543.     END.
  544. {$ENDC}
  545.